/**
 * 文件描述：字符编码过滤器
 * 创建人： SPGLP55
 * 创建时间：2024/10/31
 * 最后编辑人：SPGLP55
 * 最后编辑时间：2024/10/31
 * 文件版本：1
 */

package com.gxuwz.lhleavesys.web.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;

import java.io.IOException;

@WebFilter(filterName = "CharacterEncodingFilter", urlPatterns = { "/*" })
public class CharacterEncodingFilter implements Filter {

    private final static String ENCODE = "UTF-8";

    @Override
    public void init(FilterConfig config) throws ServletException {
        //TODO: init
    }

    @Override
    public void destroy() {
        //TODO: destroy
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws ServletException, IOException {
        // default charset is UTF-8
        request.setCharacterEncoding(ENCODE);
        response.setCharacterEncoding(ENCODE);
        chain.doFilter(request, response);
    }

}
